package util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Convert {
	private static SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy");
	
	public static String dateToString(Date data) throws Exception {
		if(data == null) return null;
		return sf.format(data).toString();
	}
	
	public static String dateObjectToString(Object obj) throws Exception {
		if(obj == null) return null;
		return sf.format(obj).toString();
	}
	
	public static Date stringToDate(String data) throws Exception {
		if (data == null || data.equals(""))
			return null;
		Date dataFormatada = null;
		try {
			DateFormat formatter = sf;
			dataFormatada = (java.util.Date)formatter.parse(data);
		} catch (ParseException e) {
			throw e;
		}
		return dataFormatada;
	}
}
